<template>
	<view>
			<view class="search h80">
				<view class="searchbox flex pr20 pl80">
					<view class="searchIcon flex col-center flex1">
						<image src="/static/image/index/search.png" class="w24 h24 mr10"></image>
					</view>
					<u-input v-model="name" type="text" :border="false" :custom-style='customStyle' placeholder="请输入内容" trim  :clearable='false'
					placeholder-style='color: #FFFFFF;' class="w-max"/>
					<view class="flex row-right" @click="searchBtn">
						<text>搜索</text>
					</view>
				</view>
			</view>
	</view>
</template>

<script>

	export default {
		name:"search",
		props:{
			from:{
				type:Number,
				required:false
			},
			searchQuery:{
				type:Object,
				required:false
			}
		},
		data() {
			return {
				name:'',
				customStyle:{
					color:'#fff',
				},
			};
		},
		methods:{
			searchBtn() {
				if(this.name=='') {
					this.$msg('请输入搜索内容')
					return
				}
				uni.setStorageSync('searchQuery',this.searchQuery)
				let api=''
				//from==1产品中心搜索接口
				this.from==1? api='qualityGoods' : api='searchIndex'
				this.searchQuery.name=this.name
				this.$api[api](this.searchQuery).then(res=>{
					console.log(res)
					uni.setStorageSync('searchList',res.data)
					if(this.from==1) {
						uni.navigateTo({
							url:'/subpkg/Newrelease/Newrelease?type=1&tit=搜索结果&from='+this.from
						})
					}else {
						uni.navigateTo({
							url:'/subpkg/Newrelease/Newrelease?type=1&tit=搜索结果'
						})
					}
					
				})
			}
		}
	}
</script>

<style lang="scss">
.search {
			.searchbox {
				position: relative;
				height: 68rpx;
				background: #E89797;
				border-radius: 34rpx;
				// text-align: center;
				line-height: 68rpx;
				width: 100%;

				.searchIcon {
					position: absolute;
					top: 50%;
					left: 40rpx;
					transform: translateY(-50%);
				}
				text {
					font-size: 26rpx;
					font-weight: 400;
					color: #FFFFFF;
				}
			}
		}
</style>
